import { App, inject } from "vue";
import PageStackComponent, {
  install as PageStackInstall,
  PageStackOptions,
  ProvideKey,
  ProvideValue,
} from "./PageStack.vue";
import { RouterView, RouterLink } from "vue-router";

export default {
  install(app: App, options: PageStackOptions) {
    PageStackInstall(app, options);
    app.component(PageStackComponent.name, PageStackComponent);
  },
};

export const PageStack = PageStackComponent;

export function usePageStack() {
  return inject(ProvideKey) as ProvideValue;
}

// 定义全局申明
declare module "vue" {
  interface GlobalComponents {
    PageStack: typeof PageStackComponent;
    RouterView: typeof RouterView;
    RouterLink: typeof RouterLink;
  }
}
